import request from '_utils/request'

// 请求分类接口
const fetchCate = (params = {}) => request.get('/shop/goods/category/all', { params })
// 获取首页轮播
const fetchHomeBanner = (params = {}) => request.get('/banner/list', { params })

// 获取列表数据
const fetchItem = (params = {}) => request.post('/shop/goods/list/v2', params)

// 获取商品详情
const fetchDetail = (id) => request.get('/shop/goods/detail', {
  params: {
    id
  }
})
// 注册接口
const fectRegister = (params = {}) => request.post('/user/username/register', params)

// 登录接口
const fectchLogin = (params = {}) => request.post('/user/username/login', params)
// 加入购物车
const fetchAddCart = (params = {}) => request.post('/shopping-cart/add', params)

// 获取购物车数据
const fechCartStatus = (params = {}) => request.get('/shopping-cart/info', { params })

// 修改购物车商品购买数量
const modifyItemNum = (params = {}) => request.post('/shopping-cart/modifyNumber', params)

// 修改购物车状态
const itemStateChange = (params = {}) => request.post('/shopping-cart/select', params)
// 删除购物车商品
const delItem = (params = {}) => request.post('/shopping-cart/remove', params)

// 添加地址
const fetchAddress = (params = {}) => request.post('user/shipping-address/add', params)

// 地址列表
const fetchAddressList = (params = {}) => request.post('/user/shipping-address/list/v2', params)

// 地址详情
const fetchAddressDetail = (params = {}) => request.get('/user/shipping-address/detail/v2', { params })

// 修改联系人地址
const fectUpdateAddress = (params = {}) => request.post('/user/shipping-address/update', params)

// 删除联系人地址
const fetchDeleteAddress = (params = {}) => request.post('user/shipping-address/delete', params)

// 用户详情
const userDetail = (params = {}) => request.get('/user/detail', { params })

// 退出登录
const fetchExitLogin = (params = {}) => request.get('/user/loginout', { params })

// 修改用户信息
const fectUserMessage = (params = {}) => request.post('/user/modify', params)

// 上传图片到服务器
const fetchUpload = (params = {}) => request.post('/dfs/upload/file', params)

export {
  fetchCate,
  fetchHomeBanner,
  fetchItem,
  fetchDetail,
  fectRegister,
  fectchLogin,
  fetchAddCart,
  fechCartStatus,
  modifyItemNum,
  itemStateChange,
  delItem,
  fetchAddress,
  fetchAddressList,
  fetchAddressDetail,
  fectUpdateAddress,
  fetchDeleteAddress,
  userDetail,
  fetchExitLogin,
  fectUserMessage,
  fetchUpload
}
